<!DOCTYPE html>
<html>
<head>
	<title>系统资源监控</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript">
	    var path = window.document.location.href;
		var pathName = window.document.location.pathname;
		var hostPath = path.substring(0, path.indexOf(pathName));
		var projectName = pathName.substring(0, pathName.substr(1).indexOf("/") + 1);
		document.write('<scr' + 'ipt src="' + projectName + '/js/html/header.js"></scr'+'ipt>');
    </script>
</head>
<body>
	<table id="dg1" class="easyui-datagrid" style="width:auto;height:auto">
		<thead>
			<tr>
				<th data-options="field:'memoryName',width:100,align:'center'">内存</th>
				<th data-options="field:'initMemory',width:100,align:'center'">初始值</th>
				<th data-options="field:'usedMemory',width:100,align:'center'">已使用</th>
				<th data-options="field:'committedMemory',width:100,align:'center'">分配</th>
				<th data-options="field:'maxMemory',width:100,align:'center'">最大值</th>
			</tr>
		</thead>
	</table>
	<div style="width:auto;height:10px"></div>
	<table id="dg2" class="easyui-datagrid" style="width:auto;height:auto">
		<thead>
			<tr>
				<th data-options="field:'threadCount',width:100,align:'center'">活动线程</th>
				<th data-options="field:'daemonThreadCount',width:100,align:'center'">守护线程</th>
				<th data-options="field:'peakThreadCount',width:100,align:'center'">峰值</th>
				<th data-options="field:'totalStartedThreadCount',width:100,align:'center'">已启动的总数</th>
			</tr>
		</thead>
	</table>
	<div style="width:auto;height:10px"></div>
	<table id="dg3" class="easyui-datagrid" style="width:auto;height:auto">
		<thead>
			<tr>
				<th data-options="field:'threadName',width:100,align:'center'">线程名</th>
				<th data-options="field:'threadId',width:100,align:'center'">线程ID</th>
				<th data-options="field:'threadState',width:100,align:'center'">线程状态</th>
				<th data-options="field:'waitedCount',width:100,align:'center'">等待总数</th>
				<th data-options="field:'blockedCount',width:100,align:'center'">阻塞总数</th>
			</tr>
		</thead>
	</table>
	<script>
		var initd = {
			queryDataURL: "/monitor/jvm",//查询URL
			dg1:$('#dg1'),
			dg2:$('#dg2'),
			dg3:$('#dg3')
		};

		initd.dg1.datagrid({
			url: initd.queryDataURL,
			method: 'post',
			iconCls: 'icon-search',
			striped: true,
			nowrap: true,
			border: true,
			idField: 'id',
			singleSelect: true,
			rownumbers: true,
			fit: false,
			fitColumns: true,
			loadMsg: '数据加载中……',
			toolbar: '#dg-buttons',
			onClickRow: initd.onClickRow,
			pagination: true,
			pageNumber: 1,
			pageList: [10, 20, 50, 100],
			pageSize: initd.pageSize,
			queryParams: {"jmType":"1"},
			loadFilter: amsDataFilter,
			loader: function(param, success, error) {
				$.ajax({
					type: "POST",
					url: projectName + initd.queryDataURL,
					data: JSON.stringify(param),
					dataType: "json",
					contentType : "application/json;charset=utf-8",
					success: function(data) {
						$.messager.progress("close");
						if (!data.success) {
							$.messager.alert("错误提示", '[' + data.code + ']' + data.message);
							return;
						}
						success(data);
					},
					error: function (err, status) {
						$.messager.progress("close");
						$.messager.alert("错误提示", '[' + err.status + ']' + err.responseText);
						initd.dg.datagrid('loaded');
					}
				});
			},
			onLoadSuccess: function (data) {
				$.messager.progress("close");
				rememberQueryParam();
			},
			onLoadError: function (err) {
				$.messager.progress("close");
				errorMsgAlert(err);
			}
		});

		initd.dg2.datagrid({
			url: initd.queryDataURL,
			method: 'post',
			iconCls: 'icon-search',
			striped: true,
			nowrap: true,
			border: true,
			idField: 'id',
			singleSelect: true,
			rownumbers: true,
			fit: false,
			fitColumns: true,
			loadMsg: '数据加载中……',
			toolbar: '#dg-buttons',
			onClickRow: initd.onClickRow,
			pagination: true,
			pageNumber: 1,
			pageList: [10, 20, 50, 100],
			pageSize: initd.pageSize,
			queryParams: {"jmType":"2"},
			loadFilter: amsDataFilter,
			loader: function(param, success, error) {
				$.ajax({
					type: "POST",
					url: projectName + initd.queryDataURL,
					data: JSON.stringify(param),
					dataType: "json",
					contentType : "application/json;charset=utf-8",
					success: function(data) {
						$.messager.progress("close");
						if (!data.success) {
							$.messager.alert("错误提示", '[' + data.code + ']' + data.message);
							return;
						}
						success(data);
					},
					error: function (err, status) {
						$.messager.progress("close");
						$.messager.alert("错误提示", '[' + err.status + ']' + err.responseText);
						initd.dg.datagrid('loaded');
					}
				});
			},
			onLoadSuccess: function (data) {
				$.messager.progress("close");
				rememberQueryParam();
			},
			onLoadError: function (err) {
				$.messager.progress("close");
				errorMsgAlert(err);
			}
		});

		initd.dg3.datagrid({
			url: initd.queryDataURL,
			method: 'post',
			iconCls: 'icon-search',
			striped: true,
			nowrap: true,
			border: true,
			idField: 'id',
			singleSelect: true,
			rownumbers: true,
			fit: false,
			fitColumns: true,
			loadMsg: '数据加载中……',
			toolbar: '#dg-buttons',
			onClickRow: initd.onClickRow,
			pagination: true,
			pageNumber: 1,
			pageList: [10, 20, 50, 100],
			pageSize: initd.pageSize,
			queryParams: {"jmType":"3"},
			loadFilter: amsDataFilter,
			loader: function(param, success, error) {
				$.ajax({
					type: "POST",
					url: projectName + initd.queryDataURL,
					data: JSON.stringify(param),
					dataType: "json",
					contentType : "application/json;charset=utf-8",
					success: function(data) {
						$.messager.progress("close");
						if (!data.success) {
							$.messager.alert("错误提示", '[' + data.code + ']' + data.message);
							return;
						}
						success(data);
					},
					error: function (err, status) {
						$.messager.progress("close");
						$.messager.alert("错误提示", '[' + err.status + ']' + err.responseText);
						initd.dg.datagrid('loaded');
					}
				});
			},
			onLoadSuccess: function (data) {
				$.messager.progress("close");
				rememberQueryParam();
			},
			onLoadError: function (err) {
				$.messager.progress("close");
				errorMsgAlert(err);
			}
		});

	</script>
</body>
</html>